package com.zjpg.forum.config;

import com.zjpg.forum.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @ClassName AppInterceptorConfigurer
 * @Description: TODO
 * @Author: JCC
 * @CreateTime: 2023/8/15 16:43
 */
@Configuration
public class AppInterceptorConfigurer implements WebMvcConfigurer {
    // 注入自定义的登录拦截器
    @Resource
    private LoginInterceptor interceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/sign-in.html")
                .excludePathPatterns("/sign-up.html")
                .excludePathPatterns("/user/reg")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/loginout")
                .excludePathPatterns("/v3*/**")
                .excludePathPatterns("/swagger*/**")
                .excludePathPatterns("/dist/**")
                .excludePathPatterns("/image/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/**.ico");
    }
}
